/*
 ID: brodyzt1
 PROG: beads
 LANG:C++
 */

#include <iostream>
#include <fstream>
#include <string>

using namespace std;

int beadsCollectedAfter (int index, int direction, string necklace)
{
    int iterations = 0;
    int collected = 1;
    int currentBead;
    char firstBead;
    if (direction == -1) {
        firstBead = necklace[index];
        currentBead = index - 1;
    }
    else {
        if(index == (int)(necklace.length() - 1))
        {
            firstBead = necklace[0];
            currentBead = 1;
        }
        else
        {
            firstBead = necklace[index + 1];
            currentBead = index + 2;
        }
    }
    
    if (firstBead == 'w') {
        int tempCurrentBead = currentBead;
        while (necklace[tempCurrentBead] == 'w') {
            tempCurrentBead += direction;
            if (tempCurrentBead < 0) {
                tempCurrentBead = (int)(necklace.length() - 1);
            }
            else if(tempCurrentBead > (int)(necklace.length() - 1))
            {
                tempCurrentBead = 0;
            }
            iterations += 1;
            if (iterations == necklace.length() - 1) {
                return (int)necklace.length();
            }
        }
        firstBead = necklace[tempCurrentBead];
    }
    
    if (currentBead < 0) {
        currentBead = (int)(necklace.length() - 1);
    }
    else if(currentBead > (int)(necklace.length() - 1))
    {
        currentBead = 0;
    }
    iterations = 0;
    while (necklace[currentBead] == firstBead || necklace[currentBead] == 'w') {
        currentBead += direction;
        if (currentBead < 0) {
            currentBead = (int)(necklace.length() - 1);
        }
        else if(currentBead > (int)(necklace.length() - 1))
        {
            currentBead = 0;
        }
        collected +=1;
        iterations += 1;
        if (iterations == necklace.length() - 1) {
            break;
        }
    }
    
    return collected;
}

int totalCollectedAfter (int index, string necklace)
{
    int totalCollected = 0;
    totalCollected += beadsCollectedAfter(index, -1, necklace);
    totalCollected += beadsCollectedAfter(index, 1, necklace);
    if (beadsCollectedAfter(index, 1, necklace) == necklace.length()) {
        totalCollected = beadsCollectedAfter(index, 1, necklace);
    }
    if (totalCollected > necklace.length()) {
        totalCollected = (int)necklace.length();
    }
    return totalCollected;
}

int main(int argc, const char * argv[])
{
    string necklace;
    int stringLength;
    ifstream input;
    input.open("beads.in");
    input >> stringLength;
    input >> necklace;
    //necklace = "rrrrrrrrrrrrrrrrrrrrbbbbbbbbbbbbbbbbbbbbrrrrrrrrrrrrrrrrrrrrbbbbbbbbbbbbbbbbbbbbrrrrrrrrrrrrrrrrrrrrbbbbbbbbbbbbbbbbbbbbrrrrrrrrrrrrrrrrrrrrbbbbbbbbbbbbbbbbbbbbrrrrrrrrrrrrrrrrrrrrbbbbbbbbbbbbbbbbbbbb";
    int maximiumCollected = 0;
    int collectedFromCuts[(int)necklace.length()];
    for (int i = 0; i < necklace.length(); i++) {
        collectedFromCuts[i] = 0;
    }
    for (int i = 0; i < necklace.length(); i++) {
        collectedFromCuts[i] += totalCollectedAfter(i, necklace);
    }
    for (int i = 0; i < necklace.length(); i++) {
        if(collectedFromCuts[i] > maximiumCollected)
        {
            maximiumCollected = collectedFromCuts[i];
            int index = i;
            cout << "\n" << index << "\n";
        }
        
    }
    
    cout << necklace.length() << "\n";
    ofstream output;
    output.open("beads.out");
    cout << maximiumCollected << "\n";
    output << maximiumCollected << "\n";
    input.close();
    output.close();
    return 0;
}

